home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / pascal / tch_tpas.zip / PROG2.PAS < prev    next >
Pascal/Delphi Source File  |  1986-04-05  |  9KB  |  289 lines

  1. PROGRAM PROG2;
  2. {          Copyright (C), 1985 by Lyle Faurot.  All rights reserved.
  3.  
  4. Note that this program is not a program to compile and run,
  5. but a tutorial on editing programs.
  6.  
  7. PROG2 is part of TURBO-LESSON 2.
  8.  
  9. OBJECTIVE 3.  Move the cursor to desired location.
  10. (See TURBO-LESSON 2 for list of objectives).
  11.  
  12. One of the basics of any screen editor or word processor is the
  13. ability to move around the screen easily.  The arrow keys at the
  14. right of the keyboard are used to move the cursor.  Note that
  15. the following may be substituted for the arrow keys:
  16.  
  17.        ctrl-s  = left-arrow
  18.        ctrl-d  = right-arrow
  19.        ctrl-e  = up-arrow
  20.        ctrl-x  = down-arrow
  21.  
  22. ##### DO:
  23.  
  24. Try out the cursor movement keys by moving the cursor to the
  25. numbers below in order starting at 1:
  26.  
  27.                        1
  28.                                            4
  29.                 3
  30.        5
  31.                2         6
  32.  
  33. ##### DO:
  34.  
  35. Move the cursor around while watching the top line of this
  36. screen.  The line and column are always indicated there
  37. if you need this information.
  38.  
  39. Notice that the screen can be "pushed" up or down by holding
  40. down the up-arrow or down-arrow.  
  41.  
  42. ##### DO:
  43.  
  44. Try out this feature by scrolling to the beginning of this 
  45. program, using the up-arrow, and then scrolling back here using 
  46. the down-arrow.  
  47.  
  48. Was that a little slow?  There are some faster ways to move the
  49. cursor if you are moving it more than a few spaces or lines.
  50. Instead of using the up-arrow to scroll to the beginning of this
  51. file, you could have used ctrl-PgUp.  
  52.  
  53. ##### DO:
  54.  
  55. Try ctrl-PgUp then return here using the down arrow.  To get to 
  56. the end of the file, use ctrl-PgDn.  Before you try that, you 
  57. should know that PgUp and PgDn without the control key will move 
  58. the cursor up or down one screen at a time.  
  59.  
  60. ##### DO:
  61.  
  62. Try crtl-PgDn to move the cursor to the end of this file and 
  63. return here using ctrl-PgUp.  
  64.  
  65. Another useful combination is ctrl-left-arrow and ctrl-right-arrow.
  66. By using the control key with the left and right arrow keys you can
  67. move left or right one word at a time.
  68.  
  69. ##### DO:
  70.  
  71. Use ctrl-left-arrow and ctrl-right-arrow to move the cursor back 
  72. and forth one word at a time on these two lines. 
  73.  
  74. Also try crtl-up-arrow.  What happened?  Only the left and right 
  75. arrow keys are combined with the control key for cursor control.  
  76.  
  77. The Home and End keys are also used for cursor control.  
  78.  
  79. ##### DO:
  80.  
  81. Try the Home and End keys.  
  82.  
  83. What happens?  This gives you a quick way to get to the beginning 
  84. or end of a line.  You will find the End key especially useful in 
  85. writing programs.  
  86.  
  87. What cursor movement results when you combine the control key 
  88. with Home and End.  Try it!  
  89.  
  90. ##### DO:
  91.  
  92. Experiment with ctrl-Home and ctrl-End.
  93.  
  94. This provides a quick route to the top or bottom of the current 
  95. screen.  
  96.  
  97. LEARNING THESE CURSOR MOVEMENT KEYS AND KEY COMBINATIONS NOW
  98. WILL SAVE TIME AND FRUSTRATION LATER WHEN YOU ARE WORKING
  99. ON PROGRAMS!  YOU MAY WANT TO POST THE FOLLOWING LIST BY YOUR
  100. COMPUTER UNTIL YOU BECOME COMFORTABLE WITH EDITING.
  101.  
  102.      Left-arrow       Left one character
  103.      Right-arrow      Right one character
  104.      Ctrl-Left-arrow  Left one word
  105.      Ctrl-Right-arrow Right one word
  106.      Home             Left end of current line
  107.      End              Right end of current line
  108.      Ctrl-Home        Top of current screen
  109.      Ctrl-End         Bottom of current screen
  110.      PgUp             Previous screen
  111.      PgDn             Next screen
  112.      Ctrl-PgUp        Beginning of file
  113.      Ctrl-PgDn        End of file
  114. (Program PROG2A will print this table.)
  115.  
  116.  
  117. OBJECTIVE 4.  Insert/replace text.
  118.  
  119. There are two ways to type text when using an editor or word
  120. processor:  
  121.  
  122. (1) Insert new text while pushing existing text to the right to 
  123. make room for the new text, and 
  124.  
  125. (2) Replace text by typing over the original text.  
  126.  
  127. ##### DO:
  128.  
  129. Look at the top line of this screen while depressing the Ins
  130. key several times.  The status line indicates "Insert" or
  131. "Overwrite" mode is presently active.  The Ins key gives you
  132. a way to switch modes.
  133.  
  134. ##### DO:
  135.  
  136. Try the two typing modes on the practice text below:
  137.  
  138. *************************************************************
  139.       PRACTICE TEXT: DON'T WORRY ABOUT MAKING A MISTAKE --
  140. THIS TEXT IS HERE FOR YOUR EXPERIMENTATION.  Use the better
  141. of the two modes to correct mistakes, insert some new text
  142. (how about a nice, overworked term like "user-friendly"),
  143. and change some of the upper case text to lower case.
  144.  
  145. There ar  sume mistekes hear   for you to coreect.
  146.  
  147. Use the Insert mode with the right arrow and the space bar
  148. to correct the following:
  149. Thequickbrownfoxjumpedoverthelazydog'sback.
  150. *************************************************************
  151.  
  152.  
  153. OBJECTIVE 5.  Delete text.
  154.  
  155. There are several ways to delete text:
  156.  
  157. (1) Use the Del key or ctrl-G to delete the character at the
  158. cursor position and pull the characters from the right.  You
  159. might think of this as "eating" the characters to the right.
  160.  
  161. ##### DO:
  162.  
  163. Use the Del key and Ctrl-G to eliminate the x's below:
  164.  
  165. abcdexxxfghijkxxxxxxxxlmxnopxxxqrstxxxxxxxxxxxxxxxuvwxyz.
  166.  
  167. (2) Use the backspace key to delete the character to the left
  168. of the cursor and pull the characters from the right.  This
  169. "eats" characters to the left.  
  170.  
  171. ##### DO:
  172.  
  173. Use the backspace to eliminate the letters from f to k in the 
  174. practice line above.  
  175.  
  176. NOTE THAT Del, ctrl-G, and backspace WORK THE SAME WAY IN
  177. EITHER INSERT OR OVERWRITE MODE.
  178.  
  179. (3) Use the space bar to space out characters in the OVERWRITE
  180. mode.  You shouldn't need this very often if you learn to use
  181. the other methods for deleting text.
  182.  
  183. (4) Use ctrl-Y to delete the entire line.  
  184.  
  185. ##### DO:
  186.  
  187. Delete the blank line and the extra Line2 below using ctrl-Y:
  188.        Line 1
  189.        Line 2
  190.        Line 2
  191.        Line 3
  192.  
  193.        Line 4
  194.        Line 5
  195.  
  196.  
  197. OBJECTIVE 6.  Auto-tab for readable programs.
  198.  
  199. PASCAL provides very good tools for structuring programs.
  200. The advantages gained from carefully structuring a program will
  201. be wasted if the program itself is not typed in a manner which
  202. makes the structure clear.  Tabbing in this editor is a little
  203. different - depressing the tab key advances the cursor to a
  204. position under the next word in the previous line!  That may
  205. seem a little strange, but don't make up your mind until you
  206. try the both exercises in this section.  
  207.  
  208. On a typewriter the tabs are fixed.  Each time you depress the
  209. TAB key you move so many spaces.  TURBO sets the tabs by looking
  210. at the line immediately above the cursor.  The first letter in
  211. each word is the position of your tab for the line below.
  212.  
  213. For example, this line sets tabs in the positions numbered below:
  214. 1   2        3    4    5    6    7  8   9         10       11
  215.  
  216. When I type in a different line, the tabs change--like this
  217. 1    2 3    4  5 6         7     8   9    10           11
  218.  
  219. This makes it easy to line up program commands with tabs:
  220.  
  221. No indent on this line.  Typing return and TAB after here
  222.    Produces first indent under the "i." Typing return here
  223.    Continues under the letter "P."  Typing return then TAB here
  224.              Indents under the letter "u."  Return after here
  225.              Lines up under "I."  Return again after here
  226.              Does the same!
  227.  
  228. In the sample program below, the first line is entered manually,
  229. resulting in tabs at characters "i" ":" "I" on the first line.
  230.  
  231. ##### DO:
  232.  
  233. Try the tab feature by typing in the following program segment: 
  234.  
  235. VAR   i,j,k          : Integer; 
  236.       a,b,c,d        : Real;
  237.       First_Name     : String[10];
  238.       Last_Name      : String[16];
  239.       Zip            : String[5];
  240.  
  241. (With the Insert mode on, the program segment may be typed in
  242. below without overwriting the text that follows.)
  243.  
  244.  
  245.  
  246.  
  247. A feature based on this tabbing technique is used to provide
  248. "structured" indentation of statement lines.  
  249.  
  250.  
  251. ##### DO:
  252.  
  253. Watch the line at the top of the screen as you depress ctrl-Q 
  254. followed by ctrl-I several times.  
  255.  
  256. The word, Indent, should toggle on and off.  When Indent appears 
  257. in the status line, the automatic indentation feature is active.  
  258.  
  259. When the enter key is depressed, the cursor will return to a 
  260. position under the leftmost word of the previous line if the 
  261. Indent feature is active.  Otherwise, the cursor returns to the 
  262. left margin.  
  263.  
  264. Remember ctrl-Q, ctrl-I will toggle this feature off (and back 
  265. on) in case it gets in your way at times.  
  266.  
  267. ##### DO:
  268.  
  269. Try typing in the following statements with the Indent feature
  270. on to see how it works:
  271.  
  272. BEGIN
  273.   REPEAT
  274.      i := i + k;
  275.      c := a + b;
  276.      REPEAT
  277.         ReadLn(First_Name);
  278.         ReadLn(Last_Name);
  279.         WriteLn(First_Name, ' ',Last_Name);
  280.      UNTIL Last_Name = 'ZZZ';
  281.      WriteLn('All names printed');
  282.   UNTIL i > 20;
  283. END.
  284.  
  285. ********** End of PROG2 tutorial ******************
  286. }
  287.  
  288.  
  289.